home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C ++ / Frameworks / MacZoop 1.6.5 / More Classes / File Classes / ZFile.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-02-26  |  2.0 KB  |  104 lines  |  [TEXT/CWIE]

  1. /*************************************************************************************************
  2. *
  3. *
  4. *            ObjectMacZapp        -- a standard Mac OOP application template
  5. *
  6. *
  7. *
  8. *            ZFile.h    -- a generic file object
  9. *
  10. *
  11. *
  12. *
  13. *
  14. *            © 1996, Graham Cox
  15. *
  16. *
  17. *
  18. *
  19. *************************************************************************************************/
  20.  
  21.  
  22.  
  23. #pragma once
  24.  
  25. #ifndef __ZFILE__
  26. #define    __ZFILE__
  27.  
  28. #ifndef __ZCOMRADE__
  29. #include    "ZComrade.h"
  30. #endif
  31.  
  32. #include    <Files.h>
  33.  
  34.  
  35.  
  36. class    ZFile : public ZComrade
  37. {
  38. protected:
  39.  
  40.     short    refNum;            // data fork ref num when open
  41.     short    resRefNum;        // resource fork ref num when open
  42.     Boolean    isSafeSave;        // TRUE if this was a safe-save Write
  43.     OSType    itsType;        // file type
  44.     FSSpec    itsSpec;        // file spec (name and location)
  45.     FSSpec    ssFSpec;        // temp file spec for safe-save
  46.     
  47. public:
  48.  
  49.     ZFile( const FSSpec& aSpec );
  50.     ZFile( Str255 fName );
  51.     ~ZFile();
  52.  
  53. // file opening and closing
  54.     virtual void    Open();
  55.     virtual void    Close();
  56.     virtual void    OpenSafe();
  57.  
  58. // creating/destroying a new file on disk    
  59.     virtual void    Create();
  60.     virtual void    Discard();
  61.  
  62. // accessing the resource fork    
  63.     virtual void    OpenResFork();
  64.     virtual void    CloseResFork();
  65.     virtual void    CreateResFork();
  66.     virtual void    SetResFork( short* curRes );
  67.  
  68. // reading and writing file data    
  69.     virtual void    Read( Ptr inBuffer, long* howMuch );
  70.     virtual void    Write( Ptr outBuffer, long* howMuch );
  71.     virtual void    Read( Handle aHandle );
  72.     virtual void    Write( Handle aHandle );
  73.  
  74. // file positioning and info    
  75.     virtual long    GetMark();
  76.     virtual void    SetMark( const long aMark );
  77.     
  78.     virtual OSType    GetType();
  79.     virtual void    SetType( const OSType aType );
  80.  
  81.     virtual long    GetLength();
  82.     virtual void    SetLength( const long aLength );
  83.  
  84.     virtual void    GetFSSpec( FSSpec* aSpec );
  85.  
  86. // fork info    
  87.     virtual Boolean    HasResFork();
  88.     virtual Boolean    HasDataFork();
  89.  
  90. // disk file info    
  91.     virtual Boolean    IsReal();
  92.     virtual Boolean    IsLocked();
  93.     virtual Boolean    IsOpen();
  94.     
  95. protected:
  96.     
  97.     virtual void    InitFile();
  98. };
  99.  
  100.  
  101. #define        _NOT_OPEN        -1
  102. #define        kUnknownType    '????'
  103.  
  104. #endif